package vincent.com.layouttest;

import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import vincent.com.layouttest.opengl.ImgScaleRenderer;
import vincent.com.layouttest.opengl.MyGLSurfaceView;

/**
 * Created by zhengwenchen on 2016/4/8.
 */
public class OpenGLSampleActivity extends AppCompatActivity{

    private MyGLSurfaceView mGLSurfaceView;

    private GLSurfaceView glView; // Use GLSurfaceView

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //initialize the surface view
        /*mGLSurfaceView = new MyGLSurfaceView(this);
        setContentView(mGLSurfaceView);*/

        glView = new GLSurfaceView(this); // Allocate a GLSurfaceView
        glView.setRenderer(new ImgScaleRenderer(this)); // Use a custom renderer
        glView.getAlpha();
        setContentView(glView);
    }

    @Override
    protected void onPause() {
        super.onPause();
        if(glView != null){
            glView.onPause();
        }

        if(mGLSurfaceView != null){
            mGLSurfaceView.onPause();
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(glView != null){
            glView.onResume();
        }

        if(mGLSurfaceView != null){
            mGLSurfaceView.onResume();
        }
    }
}
